package com.learn.hibernatevalidator.chapter02.propertylevel;

import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.NotNull;

/**
 * 属性约束, 属性限制使用在 getter 上而不是 set setter，也可以约束没有 setter 方法的只读属性。
 *
 * @author: liyf
 * @create: 2024-12-19 22:03
 **/
public class Car {

    private String manufacturer;

    private boolean isRegistered;

    public Car() {
    }

    public Car(String manufacturer, boolean isRegistered) {
        this.manufacturer = manufacturer;
        this.isRegistered = isRegistered;
    }

    @NotNull
    public String getManufacturer() {
        return manufacturer;
    }

    public void setManufacturer(String manufacturer) {
        this.manufacturer = manufacturer;
    }


    @AssertTrue
    public boolean isRegistered() {
        return isRegistered;
    }

    public void setRegistered(boolean registered) {
        isRegistered = registered;
    }
}
